home *** CD-ROM | disk | FTP | other *** search
/ AMIGA-CD 2 / Amiga-CD - Volume 2.iso / ungepackte_daten / 1995 / 3 / 02 / tips&tricks / wb-shortcuts / patchmenu.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-01  |  3.8 KB  |  127 lines

  1. #include <exec/execbase.h>
  2. #include <intuition/intuition.h>
  3. #include <intuition/intuitionbase.h>
  4. #include <graphics/text.h>
  5. #include <dos/rdargs.h>
  6. #include <dos/dos.h>
  7. #include <clib/dos_protos.h>
  8. #include <clib/intuition_protos.h>
  9.  
  10. #define EXTRASPACE 16
  11.  
  12. extern struct ExecBase *SysBase;
  13. extern struct IntuitionBase *IntuitionBase;
  14.  
  15. char version[] = "$VER: PatchMenu 1.3 David Göhler (15.11.94)\n";
  16. char  ArgStr   [] = "WINDOWNAME/A,MENU/A,MENUITEM/A,CHAR/A,S=SCREEN/K,SUB=SUBITEM/K,V=VERBOSE/S,CW=CORRECTWIDTH/S";
  17. LONG  ArgArray [8] = { 0,0,0,0,0,0,0,0 };
  18.  
  19. int main(int argc, char *argv[])
  20. {
  21.    int retcode = RETURN_OK;
  22.    struct RDArgs *rda = NULL;
  23.    struct Window *win = 0;
  24.    struct Screen *scr = 0;
  25.  
  26.    if (SysBase->LibNode.lib_Version < 37) return 20;
  27.  
  28.    memset(ArgArray,0,sizeof(LONG)*7);
  29.  
  30.    if (rda = ReadArgs(ArgStr,ArgArray,rda))
  31.    {
  32.       scr = LockPubScreen((STRPTR)(ArgArray[4]));
  33.       win = scr->FirstWindow;
  34.  
  35.       while (win != 0)
  36.       {
  37.          if (ArgArray[6] != 0)
  38.          {  Printf("Window: %s\n",(long)(win->Title)); }
  39.  
  40.          if (stricmp(win->Title,ArgArray[0]))
  41.          {  win = win->NextWindow;
  42.             continue;
  43.          }
  44.  
  45.          if (win == 0) {  retcode = RETURN_FAIL; break; }
  46.          else
  47.          {  struct Menu *menu = win->MenuStrip;
  48.  
  49.             if (menu == 0)
  50.             {  win = win->NextWindow;
  51.                continue;
  52.             }
  53.  
  54.             while ((menu != 0) && (stricmp(ArgArray[1],menu->MenuName)))
  55.             {
  56.                if (ArgArray[6] != 0)
  57.                {  Printf("  Menu: %s\n",(long)(menu->MenuName)); }
  58.                menu = menu->NextMenu;
  59.             }
  60.  
  61.             if (menu == 0) retcode = RETURN_FAIL + 1;
  62.             else
  63.             {  struct MenuItem *item = menu->FirstItem;
  64.  
  65.                if (ArgArray[6] != 0)
  66.                {  Printf("  Menu: %s\n",(long)(menu->MenuName)); }
  67.  
  68.                while ((item != 0) && (stricmp(ArgArray[2],((struct IntuiText *)(item->ItemFill))->IText)))
  69.                {
  70.                    if (ArgArray[6] != 0)
  71.                    {  Printf("    Item: %s\n",(long)(((struct IntuiText *)(item->ItemFill))->IText)); }
  72.                    item = item->NextItem;
  73.                }
  74.  
  75.                if ((item != 0) && (ArgArray[6] != 0))
  76.                {  Printf("    Item: %s\n",(long)(((struct IntuiText *)(item->ItemFill))->IText)); }
  77.  
  78.                if ((ArgArray[5] != 0) && (item != 0)) // SubItem gefordert
  79.                {  item = item->SubItem;
  80.  
  81.                   while ((item != 0) && (stricmp(ArgArray[5],((struct IntuiText *)(item->ItemFill))->IText)))
  82.                   {
  83.                       if (ArgArray[6] != 0)
  84.                       {  Printf("      SubItem: %s\n",(long)(((struct IntuiText *)(item->ItemFill))->IText)); }
  85.                       item = item->NextItem;
  86.                   }
  87.                }
  88.  
  89.                if (CheckSignal(SIGBREAKF_CTRL_C) == SIGBREAKF_CTRL_C)
  90.                {  retcode = RETURN_WARN;
  91.                   break;
  92.                }
  93.  
  94.                if (item == 0) retcode = RETURN_FAIL + 2;
  95.                else
  96.                {
  97.                   if (ArgArray[6] != 0)
  98.                   {  Printf("    Item: %s\n",(long)(((struct IntuiText *)(item->ItemFill))->IText)); }
  99.  
  100.                   if (strlen(ArgArray[3]) > 0)
  101.                   {  item->Flags  |= COMMSEQ;
  102.                      item->Command = *(char *)(ArgArray[3]);
  103.                      if (ArgArray[7])
  104.                      {  item->Width  += COMMWIDTH + EXTRASPACE; }
  105.                   }
  106.                   else
  107.                   {  if (ArgArray[7])
  108.                      {  item->Width  -= COMMWIDTH + EXTRASPACE; }
  109.                      item->Flags  &= ~COMMSEQ;
  110.                   }
  111.                }
  112.             }
  113.             break;
  114.          }
  115.       }
  116.  
  117.       UnlockPubScreen(0,scr);
  118.       FreeArgs(rda);
  119.    }
  120.    else
  121.    {  PrintFault(IoErr(),argv[0]);
  122.       retcode = RETURN_FAIL;
  123.    }
  124.  
  125.    return retcode;
  126. }
  127.